﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _04.SurfaceOfTheTriangleWithMath
{
    class SurfaceOfTheTriangle
    {
        static void Main(string[] args)
        {
            Console.WriteLine("How do you want to calcutale the surface ot the triangle?");
            Console.WriteLine("1-Side and an altitude to it; \n2-Three sides; \n3-Two sides and an angle between them"); 
            Console.WriteLine("The choice is yours");
            int choice = int.Parse(Console.ReadLine());
            double surface = 0.0d;
            if (choice == 1)
            {
                Console.WriteLine("Enter a side length");
                double side = double.Parse(Console.ReadLine());
                Console.WriteLine("Enter an altitude length");
                double altitude = double.Parse(Console.ReadLine());
                surface = (side * altitude) / 2;
                Console.WriteLine("The triangle surface is {0}", surface);
            }
            else if (choice == 2)
            {
                Console.WriteLine("Enter the length of first side");
                double fSide = double.Parse(Console.ReadLine());
                Console.WriteLine("Enter the length of second side");
                double sSide = double.Parse(Console.ReadLine());
                Console.WriteLine("Enter the length of third side");
                double tSide = double.Parse(Console.ReadLine());
                double HalfArea = (fSide + sSide + tSide) / 2;
                surface = Math.Sqrt(HalfArea * (HalfArea - fSide) * (HalfArea - sSide) * (HalfArea - tSide));
                Console.WriteLine("Face of the triangle is {0}", surface);
            }
            else if (choice == 3)
            {
                Console.WriteLine("Enter the length of first side");
                double fSide = double.Parse(Console.ReadLine());
                Console.WriteLine("Enter the length of second side");
                double sSide = double.Parse(Console.ReadLine());
                Console.WriteLine("Inter the angle between them in degrees");
                int angle = int.Parse(Console.ReadLine());
                double inRadians = Math.PI * angle / 180.0;
                surface = 0.5 * fSide * sSide * Math.Sin(inRadians);
                Console.WriteLine("Face of the triangle is {0}", surface);
            }
            else
            {
                Console.WriteLine("Error.Try again");
            }
        }
    }
}
